import xml.etree.cElementTree as et
import torch


def check_histc():
    a = torch.tensor([[1,2],[3,10]],dtype=torch.float)
    print(a)
    hist = torch.histc(a[:,0],bins=2)
    print(hist)


def check_argmax_mask():

    a = torch.randn(1,3,3,3,3)

    # 筛选置信度小于thresh的
    mask = a[..., 0] > 0.5
    print(mask)
    # 将置信度低于一定值的区域位置 置0
    a[..., 0] *= mask
    print(a)
    # 选取3个通道里置信度最大的那个
    b,idxs = torch.sort(a[..., 0], dim=-1)

    print(idxs)
    print(idxs.shape)


if __name__ == '__main__':
    check_histc()

# target = torch.randn(3,4,5)
# output = torch.randn(3,4,5)
#
# mask = torch.zeros_like(target,dtype=torch.bool)
# mask[0,0,0] = 1
# # mask[0,0,0]=1
# # print(target[mask]-target)
# print(torch.mean((output[mask] - target[mask]) ** 2))

# def a(x1,x2,x3):
#     print(x1,x2,x3)
#
# a(*[5,6,7])
#
#
# c = 12*[0]
# c = [2,3]
#
# x1,x2,x3 = [1,*c]
# print(x1,x2,x3)
#
# def test_xml(filepath):
#     tree = et.parse(filepath)
#     root = tree.getroot()
#
#     subroot = root.find('book')
#     print(subroot.get('category'))
#     print(subroot.find('title').text)
#
#
#
#
# test_xml(r"c:\Users\2\Desktop\xx.xml")